import Vue from 'vue'
import Vuex from 'vuex'
import user from './mudules/user'
import cart from './mudules/cart'
import getters from './getters'

Vue.use(Vuex) // vue的插件机制
import tabBar from "../utils/tabbar.js"
// Vuex.Store 构造器选项
const store = new Vuex.Store({
	state:{
		user:{},
		status:null,
		token:null,
		tabBarList: [],
	},
	mutations:{
		// 底部tabbar
		setRoleId(state,data){
			state.status = data
			state.tabBarList = tabBar[data]
			
			uni.setStorageSync('tabBarList', tabBar[0]) // 根据登录时传过来的值,存储对应的tabbarlist
		},
		setUser(state,data){
			state.user = data
		},
		setToken(state,data){
			state.token = data
		},
	},
	modules: {
		user,
		cart
	},
	getters
})
export default store
